<?php

namespace Modules\Admin\Http\Requests\Grade;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use HiCommon\Helper;
class GradeRequest extends FormRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'=>[
                'required',
                'max:20',
                Rule::unique('users_level')->ignore($this->input('id',0))//修改数据时，忽略当前数据id对应的字段验证唯一性
                // 'unique'
            ],
            // 'min_integral'=>[
            //     'required',
            //     'numeric',
            // ],
            'max_integral'=>[
                'required',
                'numeric',
            ],
           
           
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
    public function messages()
    {
        return [
            'name.required'=>'请输入等级名称',
            'name.max'=>'等级名称不能超过20字',
            'name.unique'=>'等级名称已经存在',
            // 'min_integral.required'=>'请输入等级升级最低积分',
            // 'min_integral.numeric'=>'升级最低积分必须是数值',
            'max_integral.required'=>'请输入等级升级最高积分',
            'max_integral.numeric'=>'升级最高积分必须是数值',
        ];
    }
}